package org.chenwang.projects.ehcacheaws;

import org.jets3t.service.security.AWSCredentials;

import net.sf.ehcache.CacheException;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.bootstrap.BootstrapCacheLoader;

public abstract class AmazonS3BootstrapCacheLoader implements BootstrapCacheLoader {
	
	protected String bucketName;
	
	protected String pathName;
	
	protected String pathSeparator;
	
	protected AWSCredentials credentials;

	protected boolean asynchronous;
	
	
	public AmazonS3BootstrapCacheLoader(String bucketName, String pathName,
			String pathSeparator, AWSCredentials credentials,
			boolean asynchronous) {
		super();
		this.bucketName = bucketName;
		this.pathName = pathName;
		this.pathSeparator = pathSeparator;
		this.credentials = credentials;
		this.asynchronous = asynchronous;
	}

	@Override
	public boolean isAsynchronous() {
		return this.asynchronous;
	}

	@Override
	public void load(Ehcache cache) throws CacheException {
		this.doLoad(cache);
	}
	
	protected abstract void doLoad(Ehcache cache) throws CacheException;

	@Override
	public Object clone() throws CloneNotSupportedException {
		return this.doClone();
	}
	
	protected abstract Object doClone() throws CloneNotSupportedException;

}
